package com.cw.base.jeeyc.controller;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cw.base.jeeyc.biz.intf.ApiDatabaseBiz;
import com.cw.base.common.model.dto.response.CommonRespDto;
import com.cw.base.jeeyc.api.dto.ApiDatabaseDto;
import com.cw.base.jeeyc.api.intf.ApiDatabaseApi;

/**
 * api数据库信息接口层
 *
 * @author chenw
 * @date 2019-08-24 10:59:29
 */
@RestController
@RequestMapping("/v1/apiDatabase")
@DubboService(group = "${dubbo.application.name}",version = "${dubbo.service.version}",protocol = "dubbo")
public class ApiDatabaseApiImpl implements ApiDatabaseApi {
    @Autowired
    private ApiDatabaseBiz apiDatabaseBiz;
    /**
     * 新增api数据库信息
     *
     * @param request 条件
     * @return boolean
     */
    @Override
    public CommonRespDto<Boolean> insert(@RequestBody ApiDatabaseDto request) {
        return CommonRespDto.<Boolean>builder().data(
            apiDatabaseBiz.addApiDatabase(request)).build();
    }

    /**
     * 更新api数据库信息
     *
     * @param request 条件
     * @return String
     */
    @Override
    public CommonRespDto<Boolean> modify(@RequestBody ApiDatabaseDto request) {
        return CommonRespDto.<Boolean>builder().data(
            apiDatabaseBiz.modifyApiDatabase(request)).build();
    }

    /**
     * 删除api数据库信息
     *
     * @param request 条件
     * @return boolean
     */
    @Override
    public CommonRespDto<Boolean> remove(@RequestBody ApiDatabaseDto request) {
        return CommonRespDto.<Boolean>builder().data(apiDatabaseBiz.deleteApiDatabase(request)).build();
    }
}
